function CALLBACK_123(json) {
	return json;
}



var tgd = tgd || {};
tgd.Services = tgd.Services || {};
tgd.Services.Bingo = tgd.Services.Bingo || {};

tgd.Services.Bingo.RESTClient = function () {

	if (tgd.Services.Bingo.RESTClient._initialized === undefined) {

		tgd.Services.Bingo.RESTClient.prototype.getGames = function(user, callback) {
			var self = this;

			this._request = new XMLHttpRequest();
			this._request.onreadystatechange = function() {
				if (self._request.readyState == 4) {
					self._data = eval(self._request.responseText);

					callback(self._data);
				}
			}
			this._request.open("GET", "http://meetingbingo.appspot.com/users/" + user + "/games?ts=" + new Date().getTime(), true);
			this._request.send(null);
		}

		tgd.Services.Bingo.RESTClient.prototype.createGame = function(name, user, callback) {
			var self = this;

			this._request = new XMLHttpRequest();
			this._request.onreadystatechange = function() {
				if (self._request.readyState == 4) {
					self._data = eval(self._request.responseText);

					callback(self._data);
				}
			}
			this._request.open("POST", "http://meetingbingo.appspot.com/games", true);
			this._request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			this._request.send("Name=" + name + "&CreatedBy=" + user);
		}

		/*
		 * game - unique id for game
		 * user - unique id for user
		 * words - CSV of words
		 */
		tgd.Services.Bingo.RESTClient.prototype.setWords = function(game, user, words, callback) {
			var self = this;

			this._request = new XMLHttpRequest();
			this._request.onreadystatechange = function() {
				if (self._request.readyState == 4) {
					self._data = eval(self._request.responseText);

					callback(self._data);
				}
			}
			this._request.open("POST", "http://meetingbingo.appspot.com/games/" + game + "/users/" + user + "/words", true);
			this._request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			this._request.send("Words=" + words);
		}

		/*
		 * game - unique id for game
		 * user - unique id for user
		 */
		tgd.Services.Bingo.RESTClient.prototype.getWords = function(game, user, callback) {
			var self = this;

			this._request = new XMLHttpRequest();
			this._request.onreadystatechange = function() {
				if (self._request.readyState == 4) {
					self._data = eval(self._request.responseText);

					callback(self._data);
				}
			}
			this._request.open("GET", "http://meetingbingo.appspot.com/games/" + game + "/users/" + user + "/words?ts=" + new Date().getTime(), true);
			this._request.send(null);
		}

		/*
		 * game - unique id for game
		 * word - unique id for word
		 */
		tgd.Services.Bingo.RESTClient.prototype.incrementWord = function(game, word, callback) {
			var self = this;

			this._request = new XMLHttpRequest();
			this._request.onreadystatechange = function() {
				if (self._request.readyState == 4) {
					self._data = eval(self._request.responseText);

					callback(self._data);
				}
			}
			this._request.open("POST", "http://meetingbingo.appspot.com/games/" + game + "/words/" + word + "/hit", true);
			this._request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			this._request.send(null);
		}

		/*
		 * game - unique id for game
		 */
		tgd.Services.Bingo.RESTClient.prototype.getGameData = function(game, callback) {
			var self = this;

			this._request = new XMLHttpRequest();
			this._request.onreadystatechange = function() {
				if (self._request.readyState == 4) {
					self._data = eval(self._request.responseText);

					callback(self._data);
				}
			}
			this._request.open("GET", "http://meetingbingo.appspot.com/games/" + game + "?ts=" + new Date().getTime(), true);
			this._request.send(null);
		}

		/*
		 * game - unique id for game
		 * opts - optional parameters for update - { Name : String, Status : String (AVAILABLE | ENDED), Delete : Boolean }
		 */
		tgd.Services.Bingo.RESTClient.prototype.updateGame = function(game, opts, callback) {
			var self = this;

			this._request = new XMLHttpRequest();
			this._request.onreadystatechange = function() {
				if (self._request.readyState == 4) {
					self._data = eval(self._request.responseText);

					callback(self._data);
				}
			}
			this._request.open("POST", "http://meetingbingo.appspot.com/games/" + game, true);
			this._request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			this._request.send("JSON=" + JSON.stringify(opts) + 
				(opts.Name ? "&Name=" + opts.Name : "") +
				(opts.Status ? "&Status=" + opts.Status : "") +
				(opts.Delete ? "&Delete=" + opts.Delete : ""));
		}

		/*
		 * game - unique id for game
		 * user - unique id for user
		 */
		tgd.Services.Bingo.RESTClient.prototype.joinGame = function(game, user, callback) {
			var self = this;

			this._request = new XMLHttpRequest();
			this._request.onreadystatechange = function() {
				if (self._request.readyState == 4) {
					self._data = eval(self._request.responseText);

					callback(self._data);
				}
			}
			this._request.open("POST", "http://meetingbingo.appspot.com/games/" + game + "/users/" + user, true);
			this._request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			this._request.send(null);
		}

		/*
		 * user - unique id for user
		 */
		tgd.Services.Bingo.RESTClient.prototype.getToken = function(user, callback) {
			var self = this;

			this._request = new XMLHttpRequest();
			this._request.onreadystatechange = function() {
				if (self._request.readyState == 4) {
					self._data = eval(self._request.responseText);

					callback(self._data);
				}
			}
			this._request.open("GET", "http://meetingbingo.appspot.com/users/" + user + "/token", true);
			this._request.send(null);
		}

		tgd.Services.Bingo.RESTClient._initialized = true;
	}
}
